import { http } from './http'
import { PageQueryParams, PageResponse } from '@/config/page'

export interface AclUpdateByDocParams {
  ownId: number;

  ownType: 'user' | 'team';

  umask: number;
}

export interface AclUpdateParams {
  umask: number;
}

/**
 * 批量更新指定文档的acl权限。
 */
export function batchUpdateByDoc (docId: number, params: Array<AclUpdateByDocParams>) {
  return http().post<any>(`/api/document/acl/batch/doc/${docId}`, params)
}

/**
 * 根据文档ID获取Acl列表
 */
export function queryAclByDoc (docId: number) {
  return http().get<any[]>(`/api/document/acl/doc/${docId}/acl`)
}

/**
 * 更新Acl。
 */
export function updateAcl (id: number, params: AclUpdateParams) {
  return http().put<any[]>(`/api/document/acl/${id}/`, params)
}
